﻿using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.JSON;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;

namespace RK.FormPlugin.Dz
{
    [Description("表单插件:打开Url示例"), HotUpdate]
    public class DzOpenUrl : AbstractListPlugIn
    {
        public override void BarItemClick(BarItemClickEventArgs e)
        {
            base.BarItemClick(e);
            if (e.BarItemKey.EqualsIgnoreCase("POSW_tbOpenUrl"))
            {
                // 参考资料：https://vip.kingdee.com/article/81423104462710784
                // 生成Url地址
                //var url = this.Model.GetValue("F_Jac_Text") as string;
                string url = "http://www.baidu.com";
                // 方式1：直接打开浏览器
                //this.View.AddAction("ShowWebURL", url);
                // 方式2：打开Url地址
                //var webobj = new JSONObject();
                //webobj["source"] = url;
                //webobj["height"] = 600;
                //webobj["width"] = 800;
                //webobj["isweb"] = true; // 是否新弹出一个浏览器窗口（or选项卡）打开网页地址
                //webobj["title"] = "云之家";
                //this.View.AddAction("ShowKDWebbrowseForm", webobj);
                //this.View.SendDynamicFormAction(this.View);
                JSONObject webobj = new JSONObject();
                webobj["source"] = url;
                webobj["height"] = 600;
                webobj["width"] = 910;

                //默认打开全屏显示
                webobj["isfullscreen"] = true;

                ////是否新弹出一个浏览器窗口（or选项卡）打开网页地址
                webobj["isweb"] = true;

                webobj["title"] = "OA流程图";

                this.View.AddAction("ShowKDWebbrowseForm", webobj);
                //this.View.SendAynDynamicFormAction(View);
            }
        }
    }
}
